<?
FUNCTION viewterrain($terrain,$position){
    $path="../../images/terrain/";
     SWITCH ($terrain){
        CASE '00':    //eau profonde.
          $nomterrain=$path."eau.jpg";
         BREAK;
         CASE '01':    //Plaine herbue.
          $nomterrain=$path."plaine.png";
         BREAK;
          CASE '02':   //eau peu profonde.
          $nomterrain=$path."eau.jpg";
         BREAK;
          CASE '04':    //TErrain volcanique
          $nomterrain=$path."volcanique.png";
         BREAK;

           CASE '08':   //Marrais
          $nomterrain=$path."marais.png";
         BREAK;
          CASE '09':  //Terre
          $nomterrain=$path."marais-b.png";
         BREAK;
          CASE '10':   //Foret feuillu.
          $nomterrain=$path."foret-f.png";
          BREAK;
          CASE '11':  //Foret champignon.
            $nomterrain=$path."foret-c.png";
          BREAK;
         CASE '12':  //Foret tropical
           $nomterrain=$path."foret-t.png";
         BREAK;
          CASE '13':  //Foret morte
          $nomterrain=$path."foret-morte.png";
         BREAK;
         CASE '14':  //foret de connifere.
          $nomterrain=$path."foret-con.png";
         BREAK;

          CASE '20':  //Terre gelee
          $nomterrain=$path."terregelee.png";
         BREAK;
         CASE '21':  //Foret conifere ennegee.
          $nomterrain=$path."foret-g.png";
         BREAK;
         //*********************************************************************
         // volcan
         //*********************************************************************
         CASE '35':   //Volcan actif
          $nomterrain=$path."volcan_act.png";
         BREAK;
         //*********************************************************************
         // Les desert
         //*********************************************************************
          CASE '40':   //Desert
           IF ($position/2!=floor($position/2)){$nomterrain=$path."desert1.jpg";}
           ELSE{$nomterrain=$path."desert2.jpg";}

          BREAK;
          CASE '41':  //Terre crackelee
          $nomterrain=$path."crackelee.png";
         BREAK;
         CASE '42':   //Oasis
           IF ($position/2!=floor($position/2)){$nomterrain=$path."oasis1.jpg";}
           ELSE{$nomterrain=$path."oasis2.jpg";}
           BREAK;
          //*********************************************************************
         // Les montagne et colinne
         //*********************************************************************
          CASE '50':   //Montagne
               $nomterrain=$path."mon2.png";
               BREAK;
          CASE '51':   //Montagne
               $nomterrain=$path."montagne02.png";
               BREAK;

          CASE '55':   //Colline herbue
               $nomterrain=$path."colline-herbue.png";
               BREAK;

        //*********************************************************************
         // Les plage.
         //*********************************************************************
         CASE '60':   //Montagne
               $nomterrain=$path."plage01.jpg";
         BREAK;
         CASE '61':   //Montagne
               $nomterrain=$path."plage02.jpg";
         BREAK;
         CASE '62':   //Montagne
               $nomterrain=$path."plage03.jpg";
         BREAK;
         CASE '63':   //Montagne
               $nomterrain=$path."plage04.jpg";
         BREAK;
         CASE '64':   //Montagne
               $nomterrain=$path."plage05.jpg";
         BREAK;
         CASE '65':   //Montagne
               $nomterrain=$path."plage06.jpg";
         BREAK;
         CASE '66':   //Montagne
               $nomterrain=$path."plage07.jpg";
         BREAK;
         CASE '67':   //Montagne
               $nomterrain=$path."plage08.jpg";
         BREAK;
         CASE '68':   //Montagne
               $nomterrain=$path."plage09.jpg";
         BREAK;
         CASE '69':   //Montagne
               $nomterrain=$path."plage10.jpg";
         BREAK;
         CASE '70':   //Montagne
               $nomterrain=$path."plage11.jpg";
         BREAK;
         CASE '71':   //Montagne
               $nomterrain=$path."plage12.jpg";
         BREAK;

         DEFAULT:

          $nomterrain=$path."vide.gif";
         BREAK;

     }
     RETURN $nomterrain;
}

FUNCTION viewville($ville){

        $lengt=strlen($ville);
        $sorte=substr($ville,0,1);
        $batiment_id=substr($ville,1,$lengt-1);
        

        
        SWITCH ($sorte){
             CASE 'b':
                  $query1="SELECT batiment_idbatiment FROM SDBatiment WHERE batiment_id='$batiment_id'";
                  $resultat1=mysql_query($query1);
                  $tmp1=mysql_fetch_row($resultat1);
                  $query1="SELECT batiment_icon FROM Ubatiment WHERE batiment_id='$tmp1[0]'";
                  $resultat1=mysql_query($query1);
                  $tmp1=mysql_fetch_row($resultat1);
                  $image="../../images/batiments/$tmp1[0]";

                   BREAK;
             CASE 'v':
                  $query1="SELECT ville_pic,ville_niv FROM SDville WHERE ville_id='$batiment_id'";
                  $resultat1=mysql_query($query1);
                  $tmp1=mysql_fetch_row($resultat1);
                  $tmp="$tmp1[0]"."-$tmp1[1]".".gif";
                  $image="../../images/batiment-carte/$tmp";
                 // $image="../../images/batiment-carte/$tmp1[0]";
                  BREAK;


        }//Fin du switch
RETURN $image;


}


FUNCTION detail($terrain){
        $lengt=strlen($terrain);
        $sorte=substr($terrain,0,1);
        $batiment_id=substr($terrain,1,$lengt-1);



        SWITCH ($sorte){
             CASE 'b':
                  $query1="SELECT batiment_name FROM SDBatiment WHERE batiment_id=$batiment_id";
                  $resultat1=mysql_query($query1);
                  $tmp1=mysql_fetch_row($resultat1);
                  $alt=$tmp1[0];

                   BREAK;
             CASE 'v':
                  $query1="SELECT ville_name FROM SDville WHERE ville_id='$batiment_id'";
                  $resultat1=mysql_query($query1);
                  $tmp1=mysql_fetch_row($resultat1);
                  $alt=$tmp1[0];
                  BREAK;
}
RETURN $alt ;

}
FUNCTION viewunite($unit_tmp){


$unit_id2=EXPLODE("-",$unit_tmp);
$cbm_unit=count($unit_id2);
$cbm_unit--;




  $query1="SELECT unite_icon FROM SDunite WHERE unite_id=$unit_id2[$cbm_unit]";
  $resultat1=mysql_query($query1);
  $tmp1=mysql_fetch_row($resultat1);



RETURN $tmp1[0];
}
?>
